# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""
 -------------------------------------------------
    File Name:     interface.py
    Description:   测试接口模型
 -------------------------------------------------
 """
from django.db import models

from apps.test_projects.models import TestProject
from utils.models import CoreModel, table_prefix


# Create your models here.

class InterFace(CoreModel):
    """接口表"""

    project = models.ForeignKey(
        TestProject, on_delete=models.CASCADE,
        help_text='项目id', verbose_name='项目id', db_comment='项目id'
    )
    name = models.CharField(
        max_length=50,
        help_text='接口名称', verbose_name='接口名称', db_comment='接口名称'
    )
    url = models.CharField(
        max_length=200,
        help_text='接口路径', verbose_name='接口路径', db_comment='接口路径'
    )
    method = models.CharField(
        max_length=50,
        help_text='请求方法', verbose_name='请求方法', db_comment='请求方法'
    )
    API_TYPE = [
        ('1', '项目接口'),
        ('2', '外部接口')
    ]
    type = models.CharField(
        max_length=40, choices=API_TYPE,
        default='1',
        verbose_name='接口类型', help_text='接口类型', db_comment='接口类型'
    )

    def __str__(self):
        return self.url

    class Meta:
        db_table = table_prefix + 'interface'
        db_table_comment = '接口表'

        verbose_name = "接口表"
        verbose_name_plural = verbose_name
